package com.urms.controller.menu;

import com.github.pagehelper.PageInfo;
import com.urms.entity.Menu;
import com.urms.entity.QueryMenuCondition;
import com.urms.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @PostMapping("/menuList")
    public PageInfo<Menu> menuList(QueryMenuCondition qmc) {
        return menuService.menuList(qmc);

    }

    @GetMapping("/getAllMenu")
    public List<Menu> getAllMenu() {
        return menuService.getAllMenu();
    }

    @PostMapping("/insertMenu")
    public Integer insertMenu(Menu menu) {
        return menuService.insertMenu(menu);
    }

    @PostMapping("/selectMenu")
    public PageInfo<Menu> selectMenu(QueryMenuCondition qmc) {
        return menuService.selectMenu(qmc);
    }

    @GetMapping("/deleteMenuById")
    public Integer deleteMenuById(Integer menuId) {
        return menuService.deleteMenuById(menuId);
    }

    @GetMapping("/getMenuNameByPid")
    public String getMenuNameByPid(Integer menuParentId){
        return menuService.findMenuNameById(menuParentId);
    }

    @PostMapping("/updateMenu")
    public Integer updateMenu(Menu menu){
        return menuService.updateMenu(menu);
    }

    @GetMapping("/deleteMenuList")
    public Integer deleteMenuList(Integer[]menuIds){
        return menuService.deleteMenuList(menuIds);
    }
}
